package baoliDigui;


//打印一个字符串的全部子序列，包括空字符串
public class SonString {
    public static void main(String[] args) {
        String str="abcda";
        printStr(str,0);
    }

    /*
    * @param str:要打印的子序列  index:要去掉的字符位置
    * */
    public static void printStr(String str,int index){
        if (index<str.length() &&  str!=null) {
                printStr(str, index + 1);
                String newStr = printByLess(str, index);
                System.out.println(""+newStr);
                printStr(newStr, index);
            }
        }


    public static String printByLess(String str,int index){
        StringBuilder stringBuilder = new StringBuilder();
        if (index<str.length()) {
            char[] chars = str.toCharArray();
            for (int a = 0; a < chars.length; a++) {
                if (a != index) {
                    stringBuilder.append(chars[a]);
                }
            }
        }
            return stringBuilder.toString();
    }
}
